﻿using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Enterprise.Migrations
{
    public partial class addHisDataTable : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "HIS_EXAM",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    PATIENT_ID = table.Column<string>(type: "VARCHAR(60)", nullable: true),
                    VISIT_ID = table.Column<string>(type: "VARCHAR(60)", nullable: true),
                    EXAM_NO = table.Column<string>(type: "VARCHAR(12)", nullable: true),
                    DEPT_STAYED = table.Column<string>(type: "VARCHAR(20)", nullable: true),
                    BED_NO = table.Column<int>(type: "INT", nullable: false),
                    CLIN_DIAG = table.Column<string>(type: "VARCHAR(80)", nullable: true),
                    EXAM_CLASS = table.Column<string>(type: "VARCHAR(20)", nullable: true),
                    EXAM_SUB_CLASS = table.Column<string>(type: "VARCHAR(30)", nullable: true),
                    EXAM_ITEM_CODE = table.Column<string>(type: "VARCHAR(20)", nullable: true),
                    EXAM_ITEM_NAME = table.Column<string>(type: "VARCHAR(100)", nullable: true),
                    REQ_DATE_TIME = table.Column<DateTime>(type: "DATETIME", nullable: false),
                    REQ_DOCTOR = table.Column<string>(type: "VARCHAR(10)", nullable: true),
                    EXAM_DATE_TIME = table.Column<DateTime>(type: "DATETIME", nullable: false),
                    REPORT_DATE_TIME = table.Column<DateTime>(type: "DATETIME", nullable: false),
                    EXAM_STATUS = table.Column<string>(type: "VARCHAR(1)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_HIS_EXAM", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "HIS_EXAM_REPORT",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    EXAM_NO = table.Column<string>(type: "VARCHAR(12)", nullable: true),
                    REPORT_NO = table.Column<string>(type: "VARCHAR(20)", nullable: true),
                    EXAM_PARA = table.Column<string>(type: "VARCHAR(1000)", nullable: true),
                    DESCRIPTION = table.Column<string>(type: "VARCHAR(2000)", nullable: true),
                    IMPRESSION = table.Column<string>(type: "VARCHAR(2000)", nullable: true),
                    RECOMMENDATION = table.Column<string>(type: "VARCHAR(2000)", nullable: true),
                    IS_ABNORMAL = table.Column<string>(type: "VARCHAR(1)", nullable: true),
                    FIRST_MEDIA_NAME = table.Column<string>(type: "VARCHAR(10)", nullable: true),
                    EXAM_PATH = table.Column<string>(type: "VARCHAR(256)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_HIS_EXAM_REPORT", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "HIS_LAB_RESULT",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    LAB_TEST_NO = table.Column<string>(type: "VARCHAR(20)", nullable: true),
                    ITEM_NO = table.Column<int>(type: "INT", nullable: false),
                    REPORT_ITEM_NAME = table.Column<string>(type: "VARCHAR(40)", nullable: true),
                    REPORT_ITEM_CODE = table.Column<string>(type: "VARCHAR(16)", nullable: true),
                    RESULT = table.Column<string>(type: "VARCHAR(60)", nullable: true),
                    UNITS = table.Column<string>(type: "VARCHAR(8)", nullable: true),
                    ABNORMAL_INDICATOR = table.Column<string>(type: "VARCHAR(2)", nullable: true),
                    MAXEGENT_LIMIT = table.Column<decimal>(type: "DECIMAL", nullable: false),
                    MINEGENT_LIMIT = table.Column<decimal>(type: "DECIMAL", nullable: false),
                    RESULT_RANGE = table.Column<string>(type: "VARCHAR(100)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_HIS_LAB_RESULT", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "HIS_LAB_TEST",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    PATIENT_ID = table.Column<string>(type: "VARCHAR(60)", nullable: true),
                    VISIT_ID = table.Column<string>(type: "VARCHAR(60)", nullable: true),
                    LAB_TEST_NO = table.Column<string>(type: "VARCHAR(12)", nullable: true),
                    DEPT_STAYED = table.Column<string>(type: "VARCHAR(20)", nullable: true),
                    BED_NO = table.Column<int>(type: "INT", nullable: false),
                    CLIN_DIAG = table.Column<string>(type: "VARCHAR(80)", nullable: true),
                    ITEM_NO = table.Column<int>(type: "INT", nullable: false),
                    LAB_CLASS = table.Column<string>(type: "VARCHAR(20)", nullable: true),
                    LAB_ITEM_CODE = table.Column<string>(type: "VARCHAR(20)", nullable: true),
                    LAB_ITEM_NAME = table.Column<string>(type: "VARCHAR(100)", nullable: true),
                    REQ_DATE_TIME = table.Column<DateTime>(type: "DATETIME", nullable: false),
                    REQ_DOCTOR = table.Column<string>(type: "VARCHAR(10)", nullable: true),
                    LAB_DATE_TIME = table.Column<DateTime>(type: "DATETIME", nullable: false),
                    REPORT_DATE_TIME = table.Column<DateTime>(type: "DATETIME", nullable: false),
                    LAB_STATUS = table.Column<string>(type: "VARCHAR(1)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_HIS_LAB_TEST", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "HIS_OPERATION",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    PATIENT_ID = table.Column<string>(type: "VARCHAR(60)", nullable: true),
                    VISIT_ID = table.Column<string>(type: "VARCHAR(60)", nullable: true),
                    OPERATION_ID = table.Column<string>(type: "VARCHAR(20)", nullable: true),
                    DEPT_STAYED = table.Column<string>(type: "VARCHAR(20)", nullable: true),
                    BED_NO = table.Column<int>(type: "INT", nullable: false),
                    DIAG_BEFORE_OPERATION = table.Column<string>(type: "VARCHAR(80)", nullable: true),
                    OPERATION_CODE = table.Column<string>(type: "VARCHAR(50)", nullable: true),
                    OPERATION_NAME = table.Column<string>(type: "VARCHAR(80)", nullable: true),
                    OPERATION_SCALE = table.Column<string>(type: "VARCHAR(4)", nullable: true),
                    REQ_DATE_TIME = table.Column<DateTime>(type: "DATETIME", nullable: false),
                    SCHEDULED_DATE_TIME = table.Column<DateTime>(type: "DATETIME", nullable: false),
                    OPERATION_STATUS = table.Column<string>(type: "VARCHAR(1)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_HIS_OPERATION", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "HIS_ORDERS",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    PATIENT_ID = table.Column<string>(type: "VARCHAR(60)", nullable: true),
                    VISIT_ID = table.Column<string>(type: "VARCHAR(60)", nullable: true),
                    ORDER_NO = table.Column<int>(type: "INT", nullable: false),
                    ORDER_SUB_NO = table.Column<int>(type: "INT", nullable: false),
                    REPEAT_INDICATOR = table.Column<int>(type: "INT", nullable: false),
                    ORDER_CLASS = table.Column<string>(type: "VARCHAR(1)", nullable: true),
                    ORDER_TEXT = table.Column<string>(type: "VARCHAR(800)", nullable: true),
                    ORDER_CODE = table.Column<string>(type: "VARCHAR(200)", nullable: true),
                    DOSAGE = table.Column<decimal>(type: "DECIMAL", nullable: false),
                    DOSAGE_UNITS = table.Column<string>(type: "VARCHAR(8)", nullable: true),
                    ADMINISTRATION = table.Column<string>(type: "VARCHAR(16)", nullable: true),
                    DURATION = table.Column<decimal>(type: "DECIMAL", nullable: false),
                    DURATION_UNITS = table.Column<string>(type: "VARCHAR(4)", nullable: true),
                    START_DATE_TIME = table.Column<DateTime>(type: "DATETIME", nullable: false),
                    STOP_DATE_TIME = table.Column<DateTime>(type: "DATETIME", nullable: false),
                    FREQUENCY = table.Column<string>(type: "VARCHAR(16)", nullable: true),
                    FREQ_COUNTER = table.Column<int>(type: "INT", nullable: false),
                    FREQ_INTERVAL = table.Column<int>(type: "INT", nullable: false),
                    FREQ_INTERVAL_UNIT = table.Column<string>(type: "VARCHAR(4)", nullable: true),
                    FREQ_DETAIL = table.Column<string>(type: "VARCHAR(1000)", nullable: true),
                    PERFORM_SCHEDULE = table.Column<string>(type: "VARCHAR(64)", nullable: true),
                    PERFORM_RESULT = table.Column<string>(type: "VARCHAR(8)", nullable: true),
                    ORDERING_DEPT = table.Column<string>(type: "VARCHAR(20)", nullable: true),
                    DOCTOR = table.Column<string>(type: "VARCHAR(20)", nullable: true),
                    STOP_DOCTOR = table.Column<string>(type: "VARCHAR(20)", nullable: true),
                    NURSE = table.Column<string>(type: "VARCHAR(20)", nullable: true),
                    STOP_NURSE = table.Column<string>(type: "VARCHAR(20)", nullable: true),
                    ORDER_STATUS = table.Column<string>(type: "VARCHAR(1)", nullable: true),
                    DOCTOR_USER = table.Column<string>(type: "VARCHAR(16)", nullable: true),
                    VERIFY_DATA_TIME = table.Column<DateTime>(type: "DATETIME", nullable: false),
                    DRUG_SPEC = table.Column<string>(type: "VARCHAR(20)", nullable: true),
                    FIRM_ID = table.Column<string>(type: "VARCHAR(30)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_HIS_ORDERS", x => x.Id);
                });
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "HIS_EXAM");

            migrationBuilder.DropTable(
                name: "HIS_EXAM_REPORT");

            migrationBuilder.DropTable(
                name: "HIS_LAB_RESULT");

            migrationBuilder.DropTable(
                name: "HIS_LAB_TEST");

            migrationBuilder.DropTable(
                name: "HIS_OPERATION");

            migrationBuilder.DropTable(
                name: "HIS_ORDERS");
        }
    }
}
